/*
 * main.c
 *
 *  Created on: 2017年10月18日
 *      Author: simon
 */


/*
 ============================================================================
 Name        : LinkList.c
 Author      : Simon
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include "../include/main.h"
#include "../include/s_linklist.h"
#include "../include/d_linklist.h"
int main(void) {

//	s_linklist_test();
	d_linklist_test();
	return EXIT_SUCCESS;
}
void d_linklist_test(void)
{
	//初始化双向链表
	D_PROOT d_root =  d_init_linklist();
	printf("length:%d\n",d_root->length);
	int i=0;
	D_PNODE node;
	for(i=0;i<8;i++) {
		node = d_makenode_linklist(i+1);
		d_addhead_linklist(d_root,node);
	}


	d_printfall_linklist(d_root);
	printf("length:%d\n",d_root->length);
}
void s_linklist_test(void)
{
	S_PNODE PHead = s_create_linklist();
	s_print_linklist1(PHead);
	int length = s_length_linklist(PHead);
	printf("Linklist length is:%d\n",length);
	s_insert_val_linklist(PHead,1,5);
	s_print_linklist1(PHead);
	printf("reversed1:\n");
	PHead->pNext = s_reversed_linklist1(PHead);
	s_print_linklist1(PHead);
	printf("reversed1:\n");
	PHead->pNext = s_reversed_linklist2(PHead->pNext);
	s_print_linklist1(PHead);
	printf("sorted:\n");
	s_selectsort_linklist(PHead);
	s_print_linklist1(PHead);
	S_PNODE p = s_find_linklist(PHead,1);
	printf("found :%d\n",p->data);

	printf("insert node\n");
	S_PNODE node = (S_PNODE)malloc(1*sizeof(S_NODE));
	memset(node,1,sizeof(S_NODE));
	node->data = 1111;
	s_insert_node_linklist(PHead,node,5);
	s_print_linklist1(PHead);
	return ;
}
